Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
@fontsource/roboto
Advanced tools
@fontsource/roboto is an npm package that allows you to self-host the Roboto font in your web projects. It provides a convenient way to include the Roboto font family in your application without relying on external CDNs. This package supports various font weights and styles, making it versatile for different design needs.
Basic Usage
This code imports the default Roboto font into your project. It includes the regular weight and normal style.
import '@fontsource/roboto';
Specific Font Weight
This code imports the Roboto font with a weight of 500. You can specify different weights by changing the number in the import path.
import '@fontsource/roboto/500.css';
Specific Font Style
This code imports the italic style of the Roboto font. You can combine this with different weights as needed.
import '@fontsource/roboto/italic.css';
Advanced Usage with CSS
This code imports the Roboto font with a weight of 500 and italic style. This is useful for more advanced typography needs.
import '@fontsource/roboto/500-italic.css';
The typeface-roboto package is another option for self-hosting the Roboto font. It offers similar functionality to @fontsource/roboto but is part of the older 'typeface' package series. It may not be as actively maintained as @fontsource/roboto.
The fontsource-open-sans package allows you to self-host the Open Sans font, which is another popular sans-serif typeface. It offers similar features to @fontsource/roboto, including support for various weights and styles.
The fontsource-lato package provides the Lato font family for self-hosting. Like @fontsource/roboto, it supports multiple weights and styles, making it a versatile choice for web typography.
The CSS and web font files to easily self-host the “Roboto” font. Please visit the main Fontsource website to view more details on this package.
Fontsource has a variety of methods to import CSS, such as using a bundler like Webpack. Alternatively, it supports SASS. Full documentation can be found here.
yarn add @fontsource/roboto // npm install @fontsource/roboto
Within your app entry file or site component, import it in.
import "@fontsource/roboto"; // Defaults to weight 400.
Supported variables:
[100,300,400,500,700,900]
[italic,normal]
[cyrillic,cyrillic-ext,greek,greek-ext,latin,latin-ext,vietnamese]
Finally, you can reference the font name in a CSS stylesheet, CSS Module, or CSS-in-JS.
body {
font-family: "Roboto";
}
It is important to always read the license for every font that you use. Most of the fonts in the collection use the SIL Open Font License, v1.1. Some fonts use the Apache 2 license. The Ubuntu fonts use the Ubuntu Font License v1.0.
Google Fonts License Attributions
Font version (provided by source): v30
.
Feel free to star and contribute new ideas to this repository that aim to improve the performance of font loading, as well as expanding the existing library we already have. Any suggestions or ideas can be voiced via an issue.
FAQs
Self-host the Roboto font in a neatly bundled NPM package.
The npm package @fontsource/roboto receives a total of 530,119 weekly downloads. As such, @fontsource/roboto popularity was classified as popular.
We found that @fontsource/roboto demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.